#pragma once

#include <DirectXMath.h>
#include <d3d11.h>
#include <vector>
#include "ShaderData.h"
#include "Texture.h"
#include "TriangleAccessor.h"

struct ModelRenderData
{
	ID3D11Buffer* VertexBuffer;
	ID3D11Buffer* IndexBuffer;
	DirectX::XMMATRIX Transform;
	DirectX::XMFLOAT4 Color;
	UINT vertexStride;
	UINT vertexOffset;
	int numIndizesToDraw;
	Texture* diffuseColor;
	Texture* normalMap;
};

struct ModelRawData
{
	DirectX::XMFLOAT3 Position;
	DirectX::XMFLOAT3 Rotation;
	DirectX::XMFLOAT4 Color;
	int numVertices, numIndices;
	SimpleVertex* vertices;
	WORD* indices;
};

class Model
{
public:
	Model(ModelRawData rawData, Texture& diffuseColor, Texture& normalMap);
	Model();
	~Model(void);
	const ModelRenderData* GetRenderData(void) const;
	HRESULT InitializeD3D(ID3D11Device* d3dDevice);
	void UpdateVertexBuffer( ID3D11DeviceContext* d3dDeviceContext);
	std::vector<TriangleAccessor>* GetTriangleAccessors(void);
	void ClearD3d(void);
private:
	ModelRawData m_rawData;
	ModelRenderData m_renderData;
	std::vector<TriangleAccessor> m_triangleAccessors;
};
